/* This is a generated file. Don't edit. Edit the source instead.
 */

#include <stdlib.h>
#include <stdio.h>
#include <inttypes.h>
#include "io.h"
#include "log.h"
#include "spclient.h"

int sp_send_search_all(sp_t *sp, const char *search_string, uint64_t size, int size_restriction, int file_type, int id)
{
    int rc = sp_send_command(sp, "search-all$%s$%"PRIu64"$%d$%d$%d|", search_string ? search_string : "", size, size_restriction, file_type, id);
    return rc;
}

int sp_send_search(sp_t *sp, const char *hub_address, const char *search_string, uint64_t size, int size_restriction, int file_type, int id)
{
    int rc = sp_send_command(sp, "search$%s$%s$%"PRIu64"$%d$%d$%d|", hub_address ? hub_address : "", search_string ? search_string : "", size, size_restriction, file_type, id);
    return rc;
}

int sp_send_connect(sp_t *sp, const char *hub_address, const char *nick, const char *email, const char *description, const char *speed, int passive, const char *password, const char *encoding)
{
    int rc = sp_send_command(sp, "connect$%s$%s$%s$%s$%s$%d$%s$%s|", hub_address ? hub_address : "", nick ? nick : "", email ? email : "", description ? description : "", speed ? speed : "", passive, password ? password : "", encoding ? encoding : "");
    return rc;
}

int sp_send_disconnect(sp_t *sp, const char *hub_address)
{
    int rc = sp_send_command(sp, "disconnect$%s|", hub_address ? hub_address : "");
    return rc;
}

int sp_send_public_message(sp_t *sp, const char *hub_address, const char *message)
{
    int rc = sp_send_command(sp, "public-message$%s$%s|", hub_address ? hub_address : "", message ? message : "");
    return rc;
}

int sp_send_private_message(sp_t *sp, const char *hub_address, const char *nick, const char *message)
{
    int rc = sp_send_command(sp, "private-message$%s$%s$%s|", hub_address ? hub_address : "", nick ? nick : "", message ? message : "");
    return rc;
}

int sp_send_download_file(sp_t *sp, const char *hub_address, const char *nick, const char *source_filename, uint64_t size, const char *target_filename, const char *tth)
{
    char *x_target_filename = tilde_expand_path(target_filename);
    int rc = sp_send_command(sp, "download-file$%s$%s$%s$%"PRIu64"$%s$%s|", hub_address ? hub_address : "", nick ? nick : "", source_filename ? source_filename : "", size, x_target_filename, tth ? tth : "");
    free(x_target_filename);
    return rc;
}

int sp_send_download_filelist(sp_t *sp, const char *hub_address, const char *nick, int force_update, int auto_match)
{
    int rc = sp_send_command(sp, "download-filelist$%s$%s$%u$%u|", hub_address ? hub_address : "", nick ? nick : "", force_update, auto_match);
    return rc;
}

int sp_send_download_directory(sp_t *sp, const char *hub_address, const char *nick, const char *source_directory, const char *target_directory)
{
    char *x_target_directory = tilde_expand_path(target_directory);
    int rc = sp_send_command(sp, "download-directory$%s$%s$%s$%s|", hub_address ? hub_address : "", nick ? nick : "", source_directory ? source_directory : "", x_target_directory);
    free(x_target_directory);
    return rc;
}

int sp_send_queue_remove_target(sp_t *sp, const char *target_filename)
{
    char *x_target_filename = tilde_expand_path(target_filename);
    int rc = sp_send_command(sp, "queue-remove-target$%s|", x_target_filename);
    free(x_target_filename);
    return rc;
}

int sp_send_queue_remove_source(sp_t *sp, const char *target_filename, const char *nick)
{
    char *x_target_filename = tilde_expand_path(target_filename);
    int rc = sp_send_command(sp, "queue-remove-source$%s$%s|", x_target_filename, nick ? nick : "");
    free(x_target_filename);
    return rc;
}

int sp_send_queue_remove_directory(sp_t *sp, const char *target_directory)
{
    int rc = sp_send_command(sp, "queue-remove-directory$%s|", target_directory ? target_directory : "");
    return rc;
}

int sp_send_queue_remove_nick(sp_t *sp, const char *nick)
{
    int rc = sp_send_command(sp, "queue-remove-nick$%s|", nick ? nick : "");
    return rc;
}

int sp_send_queue_remove_filelist(sp_t *sp, const char *nick)
{
    int rc = sp_send_command(sp, "queue-remove-filelist$%s|", nick ? nick : "");
    return rc;
}

int sp_send_cancel_transfer(sp_t *sp, const char *target_filename)
{
    char *x_target_filename = tilde_expand_path(target_filename);
    int rc = sp_send_command(sp, "cancel-transfer$%s|", x_target_filename);
    free(x_target_filename);
    return rc;
}

int sp_send_transfer_stats_interval(sp_t *sp, unsigned int seconds)
{
    int rc = sp_send_command(sp, "transfer-stats-interval$%u|", seconds);
    return rc;
}

int sp_send_set_port(sp_t *sp, int port)
{
    int rc = sp_send_command(sp, "set-port$%d|", port);
    return rc;
}

int sp_send_set_ip_address(sp_t *sp, const char *ip_address)
{
    int rc = sp_send_command(sp, "set-ip-address$%s|", ip_address ? ip_address : "");
    return rc;
}

int sp_send_add_shared_path(sp_t *sp, const char *path)
{
    char *x_path = tilde_expand_path(path);
    int rc = sp_send_command(sp, "add-shared-path$%s|", x_path);
    free(x_path);
    return rc;
}

int sp_send_remove_shared_path(sp_t *sp, const char *path)
{
    char *x_path = tilde_expand_path(path);
    int rc = sp_send_command(sp, "remove-shared-path$%s|", x_path);
    free(x_path);
    return rc;
}

int sp_send_shutdown(sp_t *sp)
{
    int rc = sp_send_command(sp, "shutdown|");
    return rc;
}

int sp_send_set_password(sp_t *sp, const char *hub_address, const char *password)
{
    int rc = sp_send_command(sp, "set-password$%s$%s|", hub_address ? hub_address : "", password ? password : "");
    return rc;
}

int sp_send_update_user_info(sp_t *sp, const char *speed, const char *description, const char *email)
{
    int rc = sp_send_command(sp, "update-user-info$%s$%s$%s|", speed ? speed : "", description ? description : "", email ? email : "");
    return rc;
}

int sp_send_set_slots(sp_t *sp, unsigned int slots, unsigned int per_hub_flag)
{
    int rc = sp_send_command(sp, "set-slots$%u$%u|", slots, per_hub_flag);
    return rc;
}

int sp_send_set_passive(sp_t *sp, int on)
{
    int rc = sp_send_command(sp, "set-passive$%d|", on);
    return rc;
}

int sp_send_forget_search(sp_t *sp, int search_id)
{
    int rc = sp_send_command(sp, "forget-search$%d|", search_id);
    return rc;
}

int sp_send_log_level(sp_t *sp, const char *level)
{
    int rc = sp_send_command(sp, "log-level$%s|", level ? level : "");
    return rc;
}

int sp_send_raw_command(sp_t *sp, const char *hub_address, const char *command)
{
    int rc = sp_send_command(sp, "raw-command$%s$%s|", hub_address ? hub_address : "", command ? command : "");
    return rc;
}

int sp_send_set_priority(sp_t *sp, const char *target_filename, unsigned int priority)
{
    int rc = sp_send_command(sp, "set-priority$%s$%u|", target_filename ? target_filename : "", priority);
    return rc;
}

int sp_send_rescan_share_interval(sp_t *sp, unsigned int seconds)
{
    int rc = sp_send_command(sp, "rescan-share-interval$%u|", seconds);
    return rc;
}

int sp_send_set_follow_redirects(sp_t *sp, unsigned int flag)
{
    int rc = sp_send_command(sp, "set-follow-redirects$%u|", flag);
    return rc;
}

int sp_send_grant_slot(sp_t *sp, const char *nick)
{
    int rc = sp_send_command(sp, "grant-slot$%s|", nick ? nick : "");
    return rc;
}

int sp_send_pause_hashing(sp_t *sp)
{
    int rc = sp_send_command(sp, "pause-hashing|");
    return rc;
}

int sp_send_resume_hashing(sp_t *sp)
{
    int rc = sp_send_command(sp, "resume-hashing|");
    return rc;
}

int sp_send_set_auto_search(sp_t *sp, int enabled)
{
    int rc = sp_send_command(sp, "set-auto-search$%d|", enabled);
    return rc;
}

int sp_send_set_hash_prio(sp_t *sp, unsigned int prio)
{
    int rc = sp_send_command(sp, "set-hash-prio$%u|", prio);
    return rc;
}

int sp_send_set_download_directory(sp_t *sp, const char *download_directory)
{
    int rc = sp_send_command(sp, "set-download-directory$%s|", download_directory ? download_directory : "");
    return rc;
}

int sp_send_set_incomplete_directory(sp_t *sp, const char *incomplete_directory)
{
    int rc = sp_send_command(sp, "set-incomplete-directory$%s|", incomplete_directory ? incomplete_directory : "");
    return rc;
}

int sp_send_expect_shared_paths(sp_t *sp, int num_shared_paths)
{
    int rc = sp_send_command(sp, "expect-shared-paths$%d|", num_shared_paths);
    return rc;
}
